/**
 * Copyright © 2009 Qasky. All rights reserved.
 *
 * 系统参数配置
 *
 * @author Wang Hongya
 * @version 0.0.0 2019/10/14
 *
 * History:
 * (author, date, desc)
 * (Wang Hongya, 20191014, 添加注释)
 */
import {loadSysConfigSorts,findSysConfigs,updSysConfig,delSysConfig,addSysConfig} from "api/sysConfigsApi";

const sysConfigs = {
    state: {
        tabList: [],
        page: {
            total: 0,
            currentPage: 1,
            pageSize: 10
        },
        tabListTable: [],
        getTab:false,
    },
    mutations: {
        getLoadSysConfigSortsList (state, obj) {
            const data = obj;
            state.tabList = data;
            state.getTab = true;
        },
        getSysConfigListTable (state, obj) {
            const data = obj.rows;
            state.tabListTable = data;
            state.page.total = obj.total;
            state.page.currentPage = obj.currentPage;
            state.page.pageSize = obj.pageSize;
        },
        set_getTab(state, params) {
            state.getTab = params;
        },
    },
    actions: {
        /**
         * Function    : loadSysConfigSortsAct
         * Description : 加载系统参数tab分类
         * Input       : context注册Actions   para传递的请求参数
         * Return      : 返回数据
         */
        loadSysConfigSortsAct (context) {
            loadSysConfigSorts().then(response => {
                let data = response.data;
                context.commit('getLoadSysConfigSortsList', data);
            });
        },
        /*分页获取不同tab分类系统参数信息列表*/
        findSysConfigsAct (context, para) {
            findSysConfigs(para).then(response => {
                let data = response.data;
                context.commit('getSysConfigListTable', data);
            });
        },
        /*修改单条配置信息*/
        updSysConfigAct (context, para) {
            return updSysConfig(para).then(response => {
                let data = response.data;
                return data;
            });
        },
        /*添加单条配置信息*/
        addSysConfigAct (context, para) {
            return addSysConfig(para).then(response => {
                var data = response.data;
                return data;
            });
        },
        /*删除单条配置信息*/
        delSysConfigAct (context, para) {
            return delSysConfig(para).then(response => {
                let data = response.data;
                return data;
            });
        },
    }
};

export default sysConfigs;
